package configuration

import (
	"encoding/json"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

// 道具配置
type ComposeConf struct {
	ID     int32 //  合成的道具ID
	ItemID int32 // 消耗的道具ID
	Count  int32 // 消耗的数量
}

var ComposeConfigs = map[int32]ComposeConf{}

func init() {

	var b = client.Load("ItemCompose")
	if err := json.Unmarshal(b, &ComposeConfigs); err != nil {
		panic(err)
	}

	log.Info("Load ItemCompose.json success.")
	//********************************************************************//

}

func ComposeByItemID(ID int32) (int32, int32) {

	var conf, ok = ComposeConfigs[ID]
	if !ok {
		panic(fmt.Errorf("ItemID not found [%d]", ID))
	}

	return conf.ItemID, conf.Count
}
